package presentacion;


import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;

import java.awt.BorderLayout;

import javax.swing.border.TitledBorder;

import java.awt.GridBagLayout;

import javax.swing.JLabel;

import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JPasswordField;

//import dominio.Fisioterapeuta;


import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.ImageIcon;

import dominio.Empleado;

import java.awt.SystemColor;


public class Ventana_Principal {
	
	private JPanel contentPane;
	JFrame frmGestinDe;
	private final JPanel pnlGestion = new JPanel();
	private final JLabel lblUsuario = new JLabel("Usuario");
	private final JLabel lblContrasena = new JLabel("Contraseña");
	private final JTextField txtUsuario = new JTextField();
	private final JButton btnEntrar = new JButton("Entrar");
	private final JPasswordField pfContrasena = new JPasswordField();
	private static final String login="iso2";
	private static final String nombre="Juan";
	private static final String apellidos="Garcia Perez";
	private static final String DNI="12345678-X";
	private static final String fecha_nacimiento="01/01/1969";
	private final JLabel lblLogo = new JLabel("");
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Ventana_Principal window = new Ventana_Principal();
					window.frmGestinDe.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Ventana_Principal() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmGestinDe = new JFrame();
		frmGestinDe.setResizable(false);
		frmGestinDe.setTitle("GESTION TIENDA DE MUEBLES");
		frmGestinDe.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent arg0) {
				JOptionPane.showMessageDialog(frmGestinDe,"Gracias por utilizar nuestra aplicacion","Cerrar la aplicacion", JOptionPane.PLAIN_MESSAGE);
			}
		});
		frmGestinDe.setBounds(100, 100, 434, 358);
		frmGestinDe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmGestinDe.getContentPane().setLayout(new BorderLayout(0, 0));
		{
			pnlGestion.setBorder(new TitledBorder(null, "Gestion de muebles de la tienda VesperBeeper", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			frmGestinDe.getContentPane().add(pnlGestion);
		}
		GridBagLayout gbl_pnlGestion = new GridBagLayout();
		gbl_pnlGestion.columnWidths = new int[]{126, 123, 90, 0};
		gbl_pnlGestion.rowHeights = new int[]{72, 83, 0, 21, 21, 0, 0, 0, 0};
		gbl_pnlGestion.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_pnlGestion.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		pnlGestion.setLayout(gbl_pnlGestion);
		{
			GridBagConstraints gbc_lblLogo = new GridBagConstraints();
			gbc_lblLogo.insets = new Insets(0, 0, 5, 5);
			gbc_lblLogo.gridx = 1;
			gbc_lblLogo.gridy = 1;
			lblLogo.setIcon(new ImageIcon(Ventana_Principal.class.getResource("/presentacion/logo.JPG")));
			lblLogo.setBackground(SystemColor.menu);
			lblLogo.setHorizontalAlignment(SwingConstants.CENTER);
			pnlGestion.add(lblLogo, gbc_lblLogo);
		}
		GridBagConstraints gbc_btnEntrar = new GridBagConstraints();
		gbc_btnEntrar.insets = new Insets(0, 0, 5, 5);
		gbc_btnEntrar.gridx = 1;
		gbc_btnEntrar.gridy = 6;
		btnEntrar.setHideActionText(true);
		btnEntrar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				if (txtUsuario.getText().equals("iso2")&&(pfContrasena.getText().equals("iso2"))){
					
				Empleado emp = new Empleado (login.toString(), nombre.toString(),
						apellidos.toString(), DNI.toString(), fecha_nacimiento.toString());
				
				Ventana_Menus segundaVentana = new Ventana_Menus(emp);
				segundaVentana.setVisible(true);
				frmGestinDe.setVisible(false);
			
				}else{
					JOptionPane.showMessageDialog(contentPane,"Usuario o contraseña incorrecta", "Error", JOptionPane.ERROR_MESSAGE);
				}
			}
			
		});
		{
			GridBagConstraints gbc_lblUsuario = new GridBagConstraints();
			gbc_lblUsuario.anchor = GridBagConstraints.SOUTHEAST;
			gbc_lblUsuario.insets = new Insets(0, 0, 5, 5);
			gbc_lblUsuario.gridx = 0;
			gbc_lblUsuario.gridy = 3;
			pnlGestion.add(lblUsuario, gbc_lblUsuario);
		}
		txtUsuario.setHorizontalAlignment(SwingConstants.LEFT);
		txtUsuario.setColumns(10);
		{
			GridBagConstraints gbc_txtUsuario = new GridBagConstraints();
			gbc_txtUsuario.fill = GridBagConstraints.HORIZONTAL;
			gbc_txtUsuario.insets = new Insets(0, 0, 5, 5);
			gbc_txtUsuario.gridx = 1;
			gbc_txtUsuario.gridy = 3;
			pnlGestion.add(txtUsuario, gbc_txtUsuario);
		}
		{
			GridBagConstraints gbc_lblContrasena = new GridBagConstraints();
			gbc_lblContrasena.anchor = GridBagConstraints.NORTHEAST;
			gbc_lblContrasena.insets = new Insets(0, 0, 5, 5);
			gbc_lblContrasena.gridx = 0;
			gbc_lblContrasena.gridy = 4;
			lblContrasena.setHorizontalTextPosition(SwingConstants.CENTER);
			pnlGestion.add(lblContrasena, gbc_lblContrasena);
		}
		{
			GridBagConstraints gbc_pfContrasena = new GridBagConstraints();
			gbc_pfContrasena.insets = new Insets(0, 0, 5, 5);
			gbc_pfContrasena.fill = GridBagConstraints.HORIZONTAL;
			gbc_pfContrasena.gridx = 1;
			gbc_pfContrasena.gridy = 4;
			pfContrasena.setHorizontalAlignment(SwingConstants.LEFT);
			pnlGestion.add(pfContrasena, gbc_pfContrasena);
				
		}
		pnlGestion.add(btnEntrar, gbc_btnEntrar);
		
	}
}
